home *** CD-ROM | disk | FTP | other *** search
/ The Essential Home & Business Collection / The Essential Home & Business Collection.iso / 27 / 3 / 5 / HP22D5.ZIP / EXTERN / ISSUBST.ASM < prev    next >
Assembly Source File  |  1991-04-16  |  2KB  |  107 lines

  1. DOSSEG
  2. .MODEL        LARGE
  3.  
  4. EXTRN btoh:FAR
  5. EXTRN ReturnValue:FAR
  6.  
  7. DIRSTRUCTSZ_DOS3    equ    51h    ;works for DOS 3.X
  8. DIRSTRUCTSZ_DOS4    equ    58h    ;works for DOS 5.0 too!
  9.  
  10. include        extern.inc
  11.  
  12. .DATA
  13.  
  14. pname         db        'issubst',0
  15.  
  16. Pool        PoolStruct    <pname,issubst,,FUNCTION>
  17.         PoolStruct    <>    ;END
  18.  
  19. .CODE
  20.  
  21. dtable        dd        0
  22. lastdrv        db        0
  23. tablesz        db        DIRSTRUCTSZ_DOS3
  24.  
  25.         public        WhenLoaded
  26. WhenLoaded:
  27.         mov        ah,52h
  28.         int        21h            ;ES:BX = pointer to DOS info
  29.  
  30.         mov        al,es:[bx+21h]        ;AL = last drive
  31.         mov        cs:lastdrv,al        ;save
  32.  
  33.         les        bx,es:[bx+16h]        ;ES:BX = drive table pointer
  34.         mov word ptr    cs:dtable + 2,es    ;save
  35.         mov word ptr    cs:dtable,bx
  36.  
  37.         mov        ah,30h
  38.         int        21h            ;AL = version high
  39.         cmp        al,4            ;change size if > 3.X
  40.         jb        WL1
  41.         mov        cs:tablesz,DIRSTRUCTSZ_DOS4
  42. WL1:
  43.         retf
  44.  
  45. ;
  46. ; This routine returns TRUE if a given drive letter is a subst drive, or
  47. ; FALSE otherwise.
  48. ;
  49. ; To call this routine from HyperPAD:
  50. ;
  51. ;    if issubst("F") then beep;
  52. ;
  53. issubst:    push        bp
  54.         mov        bp,sp
  55.  
  56.         mov        ax,[bp+6]    ;AX = NumArgs
  57.         cmp        ax,1
  58.         jne        _FALSE
  59.  
  60.         mov        ah,30h        ;dos version number
  61.         int        21h
  62.         cmp        al,3        ;not a subst drive if DOS < 3
  63.         jb        _FALSE
  64.  
  65.         les        bx,[bp+8]    ;ES:BX = hDrive
  66.         les        bx,es:[bx]    ;ES:BX = pDrive
  67.         mov        al,es:[bx]    ;AL = drive letter
  68.         cmp        al,'a'        ;convert to upper case
  69.         jb        IS3
  70.         cmp        al,'z'
  71.         ja        IS3
  72.         sub        al,32
  73. IS3:
  74.         sub        ax,'A'        ;AX: A = 0, B = 1, etc
  75.         cmp        al,cs:lastdrv    ;greater than last drive?
  76.         jae        _FALSE        ;not a subst drive (network?)
  77.  
  78.         cbw                ;AX = drive letter
  79.         mov        bl,cs:tablesz
  80.         mul        bl        ;AX = driveletter * tablesz
  81.         les        bx,cs:dtable    ;ES:BX = drive table
  82.         add        bx,ax        ;ES:BX = drive table entry for that drive
  83.  
  84.         mov        ax,es:[bx+43h]    ;AX = drive flags
  85.         and        ax,1000h
  86.         jz        IS2
  87.  
  88.         mov        ax,1        ;AX = TRUE (is a subst drive)
  89.  
  90. IS2:
  91.         push        ax        ;convert to boolean
  92.         call        btoh
  93.         push        dx        ;pass to HyperPAD
  94.         push        ax
  95.         call        ReturnValue
  96.  
  97.         mov        ax,STOP        ;don't pass message on
  98.         pop        bp
  99.         retf
  100.  
  101. _FALSE:        xor        ax,ax        ;return FALSE (not a subst drive)
  102.         jmp short    IS2
  103.  
  104. END
  105.  
  106.  
  107.